<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\ResourceCollection;

class PriceCollection extends ResourceCollection
{
    /**
     * Transform the resource collection into an array.
     *
     * @param \Illuminate\Http\Request $request
     * @return array|\Illuminate\Contracts\Support\Arrayable|\JsonSerializable
     */
    public function toArray($request)
    {
        return [
            'code' => 200,
            'message' => '请求成功',
            'data' => $this->collection->map(function ($item) {
                /**
                 * @var $item \App\Models\RentPrice
                 */
                return [
                    'price_id' => $item->id,
                    'name' => $item->name,
                ];
            })
        ];
    }
}
